package com.kedacom.freedomLabel.adapter;

import android.databinding.ViewDataBinding;
import android.graphics.Color;

import com.kedacom.freedomLabel.R;
import com.kedacom.freedomLabel.databinding.ItemIdLayoutBinding;
import com.kedacom.freedomLabel.model.bean.Item;
import com.kedacom.lego.adapter.recyclerview.LegoBaseRecyclerViewAdapter;

import java.util.List;

/**
 * Author：李程
 * CreateTime：2020/2/23 14:25
 * E-mail：licheng@kedacom.com
 * Describe：
 */
public class IDAdapter extends LegoBaseRecyclerViewAdapter<Item> {

    public IDAdapter(List<Item> data, int brVariableId) {
        super(R.layout.item_id_layout, data, brVariableId);
    }

    public IDAdapter(List<Item> data) {
        super(R.layout.item_id_layout, data);
    }

    @Override
    protected void onCustomBindItem(ViewDataBinding binding, int position) {
        ItemIdLayoutBinding itemBinding = (ItemIdLayoutBinding) binding;
        if (getData().get(position).isSelected()) {
            itemBinding.getRoot().setBackgroundColor(Color.DKGRAY);
            itemBinding.itemIdName.setTextColor(Color.WHITE);
        } else {
            if (position % 2 == 0) {
                itemBinding.getRoot().setBackgroundColor(Color.parseColor("#EFEFEF"));
            } else {
                itemBinding.getRoot().setBackgroundColor(Color.WHITE);
            }
            itemBinding.itemIdName.setTextColor(Color.BLACK);
        }
    }
}